<%@ page import="bean.Article" %>
<%@ page import="bean.Comment" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="bean.User" %><%--
  Created by IntelliJ IDEA.
  User: 蒋缇
  Date: 2020/10/7
  Time: 21:44
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
    ArrayList<Article> articles=(ArrayList<Article>) request.getSession().getAttribute("searchArticleResult");
    User user=(User)request.getSession().getAttribute("user");
%>
<html>
<head>
    <title>查看搜索博客内容</title>
    <link rel="stylesheet"  href="css/bootstrap.min.css"/>
    <script src="js/jquery-3.1.1.min.js"></script>
    <script src="js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="css/allStyle.css">
</head>
<body>
    <div class="row">
        <nav class="navbar navbar-default">
            <div class="container-fluid">
                <!-- Brand and toggle get grouped for better mobile display -->
                <div class="navbar-header">
                    <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                        <span class="sr-only">Toggle navigation</span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                    </button>
                    <%--                    TBLOG标签--%>
                    <a class="navbar-brand" href="#">TBLOG</a>
                </div>
                <!-- Collect the nav links, forms, and other content for toggling -->
                <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                    <%--                    主页链接--%>
                    <ul class="nav navbar-nav">
                        <li><a href="websiteHomepage.jsp">首页🏠</a></li>
                        <%--                        下拉菜单--%>
                        <li class="dropdown">
                            <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">其他 <span class="caret"></span></a>
                            <ul class="dropdown-menu">
                                <li><a href="#">Action</a></li>
                                <li><a href="#">Another action</a></li>
                                <li><a href="#">Something else here</a></li>
                                <li role="separator" class="divider"></li>
                                <li><a href="#">Separated link</a></li>
                                <li role="separator" class="divider"></li>
                                <li><a href="#">One more separated link</a></li>
                            </ul>
                        </li>
                    </ul>
                    <%--                     搜索栏--%>
                    <form class="navbar-form navbar-left">
                        <input type="text" class="form-control" size="125" maxlength="200" placeholder="请输入您想查询的内容">
                        <button type="submit" class="btn btn-default">🔍</button>
                    </form>
                    <%--                    链接--%>
                    <ul class="nav navbar-nav navbar-right">
                        <li><a href="writeBlogPage.jsp">创作中心</a></li>
                        <%--                        下拉菜单--%>
                        <li class="dropdown">
                            <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><img src="images/default.jpg" style="height: 20px;width: 20px;"><span class="caret"></span></a>
                            <ul class="dropdown-menu">
                                <li><a href="personalHompage.jsp">个人中心</a></li>
                                <li><a href="#">账号设置</a></li>
                                <li><a href="#">联系我们</a></li>
                                <li role="separator" class="divider"></li>
                                <li><a href="#">其他</a></li>
                            </ul>
                        </li>
                    </ul>
                </div><!-- /.navbar-collapse -->
            </div><!-- /.container-fluid -->
        </nav>
    </div>
    <div class="row">
        <div class="col-lg-3"></div>
        <div class="col-lg-6">
            <div class="panel panel-default" id="blog">
                <div class="panel-body">
                    <ul id="blogList" class="list-group">
                            <%
                                for(Article article:articles){
                            %>
                            <li class="list-group-item" ondblclick="browseBlog('<%=article.getId()%>')">
                            <h4><%=article.getTitle()%></h4><hr><br><font style="font-size: 5px">作者：<%=article.getUser()%>时间：<%=article.getTime()%> 浏览数：<%=article.getViews()%>
                            类型：<%=article.getType()%></font></li>
                            <%
                                }
                            %>
                    </ul>
                </div>
            </div>
        </div>
        <div class="col-lg-3"></div>
    </div>
    <script type="text/javascript">
        //浏览博客
        function browseBlog(id){
            $.ajax({
                data: {'browseArticleId': id},
                dataType: 'text',
                type: 'post',
                url: '<%=basePath%>BrowseBlogServlet',
                success: function () {
                    window.location = "<%=basePath%>blogPage.jsp";
                },
                error: function () {
                    alert("查看失败")
                }}
            );
        }
    </script>
</body>
</html>
